package com.mop.controller;

import com.mop.pojo.Item;

import com.mop.service.ItemService;
import com.mop.vo.PageResult;
import com.mop.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;



@RestController
@CrossOrigin
@RequestMapping("/item")
public class ItemController {
    @Autowired
    private ItemService itemService;
   @GetMapping("/getItemList")
   public SysResult getItemList(PageResult pageResult){
       pageResult=itemService.getItemList(pageResult);
       return SysResult.success(pageResult);
   }



   @PostMapping("/addUser")
    public SysResult addUser(@RequestBody Item item){
       itemService.addUser(item);
       return SysResult.success();
   }
   @DeleteMapping("/li/{id}")
    public SysResult deleteItem(@PathVariable Integer id){
       itemService.deleteItem(id);
       return SysResult.success();

   }
  /*  @DeleteMapping("/{id}")
    public SysResult delete1(@PathVariable Integer id){
        itemService.delete1(id);
        return SysResult.success();

    }*/
   @GetMapping("/aa/{id}")
    public SysResult findItemById(@PathVariable Integer id){
      Item item= itemService.findItemById(id);
       return SysResult.success(item);
   }
   @PutMapping("/updateItem")
    public SysResult updateItem(@RequestBody Item item){
        itemService.updateItem(item);
        return SysResult.success(item);
   }
   @PutMapping("/status/{id}/{status}")
    public SysResult updateStatus(Item item){
       itemService.updateStatus(item);
       return SysResult.success();
   }
 }
